import Vue from 'vue'
import App from './App.vue'
import router from './router/index'
import store from './store'
import Clipboard from 'v-clipboard'
import Vant from 'vant';
import commonCom from '@/components/common/index.js' // 引入公共方法
import jquery from 'jquery' // 引入jquery
import VueLazyload from 'vue-lazyload' // 懒加载
import 'normalize.css' // css reset
import './app.less' // 自定义 reset css
import 'vant/lib/index.css';

window.$ = window.jQuery = jquery

Vue.use(VueLazyload)
Vue.use(commonCom)
Vue.use(Clipboard)
Vue.use(Vant);
require('vue-video-player/src/custom-theme.css')

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')


//获取当前手机状态栏高度
let immersed = 0;
let ms = (/Html5Plus\/.+\s\(.*(Immersed\/(\d+\.?\d*).*)\)/gi).exec(navigator.userAgent);
if(ms&&ms.length>=3) { // 当前环境为沉浸式状态栏模式
immersed = parseFloat(ms[2]);// 获取状态栏的高度
}
// 判断当前系统是ios还是安卓
let u = navigator.userAgent;
let isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; //android终端
let isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if (isAndroid) {
  // window.phoneStatusBarHeight = '100px';
  // localStorage.setItem('phoneStatusBarHeight','100px')
  window.phoneStatusBarHeight = `${immersed}px`;
  localStorage.setItem('phoneStatusBarHeight',`${immersed}px`)
}
if (isIOS) {
  /* 
    iPhone 3GS  3.5吋 320x480 @1x320x480
    iPhone 4/4s  3.5吋 320x480 @2x640x960
    iPhone 5/5s/5c  4.0吋 320x568 @2x640x1136
    iPhone 6   4.7吋 375x667 @2x750x1334
    iPhone 6Plus  5.5吋 414x736 @3x1242x2208
    iPhone 6s  4.7吋 375x667 @2x750x1334
    iPhone 6sPlus  5.5吋 414x736 @3x1242x2208
    iPhone 7  4.7吋 375x667 @2x750x1334
    iPhone 7Plus  5.5吋 414x736 @3x1242x2208
    iPhone 8  4.7吋 375x667 @2x750x1334
    iPhone 8Plus5  .5吋 414x736 @3x1242x2208
    iPhone X  5.8吋 375x812 @3x1125x2436
    iPhone XS  5.8吋 375x812 @3x1125x2436
    iPhone XS Max6.5吋 414x896 @3x1242x2688
    iPhone XR  6.1吋 414x896 @2x828x1792
  */
  let iPhone4_4s = window.devicePixelRatio && window.devicePixelRatio === 2 && window.screen.width === 320 && window.screen.height === 480
  let iPhone5_5s_5c = window.devicePixelRatio && window.devicePixelRatio === 2 && window.screen.width === 320 && window.screen.height === 568
  let iPhone6_6s_7_8 = window.devicePixelRatio && window.devicePixelRatio === 2 && window.screen.width === 375 && window.screen.height === 667
  let iPhone6P_6sP_7P_8P = window.devicePixelRatio && window.devicePixelRatio === 3 && window.screen.width === 414 && window.screen.height === 736
  if(iPhone4_4s || iPhone5_5s_5c || iPhone6_6s_7_8 || iPhone6P_6sP_7P_8P){
    window.phoneStatusBarHeight = `${immersed}px`;
    localStorage.setItem('phoneStatusBarHeight', `${immersed}px`)
  }else{
    window.phoneStatusBarHeight = '48px';
    localStorage.setItem('phoneStatusBarHeight', '48px')
  }
  // window.phoneStatusBarHeight = '0px';
  // localStorage.removeItem('phoneStatusBarHeight')
}

/* 
  // 测试用
  window.phoneStatusBarHeight = '100px';
  localStorage.setItem('phoneStatusBarHeight','100px') 
*/